package cc.fs.androidcode.ui.touch;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.Button;

import cc.fs.androidcode.utils.L;
import cc.fs.androidcode.utils.T;

/**
 * Created by fostion on 2015/12/9.
 * 学习view的事件传递流程 dispatchTouchEvent  -> onTouchEvent
 */
public class MyView extends Button {
    public MyView(Context context) {
        super(context);
    }

    public MyView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
//        L.e("------------MyView  dispatchTouchEvent--------------");
        return super.dispatchTouchEvent(event);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
//        L.e("------------MyView   onTouchEvent--------------");
        T.toast("事件有子 View 处理");
        return super.onTouchEvent(event);
    }
}
